package com.singi.config;

import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;

public class WxMpConfiguration {

    private static WxMpService wxMpService;
    private  WxMpProperties properties;

    public void init() {
        properties = new WxMpProperties();
        WxMpDefaultConfigImpl configStorage = new WxMpDefaultConfigImpl();
        configStorage.setAppId(properties.getAppId());
        configStorage.setSecret(properties.getSecret());
//        configStorage.setToken(a.getToken());
//        configStorage.setAesKey(a.getAesKey());
        WxMpService service = new WxMpServiceImpl();
        service.setWxMpConfigStorage(configStorage);
        wxMpService = service;
    }

    public static WxMpService getWxMpService() {

        return wxMpService;
    }

    //    public WxMpService wxMpService() {
//
//        WxMpService service = new WxMpServiceImpl();
//        service.setMultiConfigStorages(configs
//            .stream().map(a -> {
//                WxMpDefaultConfigImpl configStorage = new WxMpDefaultConfigImpl();
//                configStorage.setAppId(a.getAppId());
//                configStorage.setSecret(a.getSecret());
//                configStorage.setToken(a.getToken());
//                configStorage.setAesKey(a.getAesKey());
//                return configStorage;
//            }).collect(Collectors.toMap(WxMpDefaultConfigImpl::getAppId, a -> a, (o, n) -> o)));
//        return service;
//    }


}
